package com.example.demo.controller;



import com.example.demo.service.LoggerService;
import com.example.demo.service.GenLogData;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author 蔡高情
 * @Description  蔡高情 测试
 * @Date 18:43 2018/8/2 0002
 * @Param
 * @return
 **/
@RestController
@RequestMapping("/log")
public class ApiController {

    @Resource
    private LoggerService loggerService;
    @RequestMapping("/show")
    public Map<String,Object> shotLog(@RequestParam("name")String name, @RequestParam("age") int age){
        Map<String,Object> result = new HashMap<String,Object>();
        result.put("name",name);
        result.put("age",age);
        for(int i=0;i<10;i++) {
            loggerService.showLog();
        }
        //throw new IllegalArgumentException("name参数的长度必须大于3，小于10！");
        return result;
    }


    @RequestMapping("/show3")
    public Map<String,Object> shotLog3(@RequestParam("name")String name, @RequestParam("age") int age){

        Map<String,Object> result=null;
        result.put("name",name);
        result.put("age",age);
        for(int i=0;i<10;i++) {
            loggerService.showLog();
        }
        //throw new IllegalArgumentException("name参数的长度必须大于3，小于10！");
        return result;
    }
    @RequestMapping("/show2")
    public void shotLog(){
        for (int i = 0; i < 10000; i++) {
            GenLogData.test2();
        }

    }


}
